package com.midian.model.organization;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.midian.common.utils.StringUtil;
import com.midian.model.common.BaseModel;
import com.midian.model.pic.Pic;
import com.midian.service.organization.IOrganizationJoinService;
import com.midian.service.organization.IOrganizationService;
import com.midian.service.user.IUserService;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Type;

import com.vividsolutions.jts.geom.Point;

/**
 * 机构加盟
 * 
 */
@Entity
@Table(name = "organization_join")
public class OrganizationJoin extends BaseModel {
	/**机构名称*/
	private String name;
//	/**机构logo*/
//	private String logo;
	/**联系人姓名*/
	private String contactPerson;
	/**联系人号码*/
	private String contactNum;
	/**联系地址*/
	private String contactAddress;
	/**机构网址*/
	private String website;
//	/**机构营业执照图片*/
//	private String businessLicense;
	/**备注*/
	private String remark;
	/**机构logo图片对象*/
	@ManyToOne(optional=true,fetch=FetchType.LAZY)
	@JoinColumn(name="logo")
	@NotFound(action=NotFoundAction.IGNORE)
	private Pic logo;
	/**营业执照图片对象*/
	@ManyToOne(optional=true,fetch=FetchType.LAZY)
	@JoinColumn(name="businessLicense")
	@NotFound(action=NotFoundAction.IGNORE)
	private Pic businessLicense;
	

	public Pic getLogo() {
		return logo;
	}

	public void setLogo(Pic logo) {
		this.logo = logo;
	}

	public Pic getBusinessLicense() {
		return businessLicense;
	}

	public void setBusinessLicense(Pic businessLicense) {
		this.businessLicense = businessLicense;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getContactPerson() {
		return contactPerson;
	}

	public void setContactPerson(String contactPerson) {
		this.contactPerson = contactPerson;
	}

	public String getContactNum() {
		return contactNum;
	}

	public void setContactNum(String contactNum) {
		this.contactNum = contactNum;
	}

	public String getContactAddress() {
		return contactAddress;
	}

	public void setContactAddress(String contactAddress) {
		this.contactAddress = contactAddress;
	}

	public String getWebsite() {
		return website;
	}

	public void setWebsite(String website) {
		this.website = website;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
	
	/**logo地址*/
	@Transient
	public String getLogoIp() {
		String logoIp="";
		if (this.logo!=null) {
			logoIp = StringUtil.getImageTips(this.logo.getId());
		}
		return logoIp;
	}
	
	/**营业执照地址*/
	@Transient
	public String getBusinessLicenseIp() {
		String businessLicenseIp="";
		if (this.businessLicense!=null) {
			businessLicenseIp = StringUtil.getImageTips(this.businessLicense.getId());
		}
		return businessLicenseIp;
	}
	
	/**
	 * 审核状态描述
	 * 
	 * @return
	 */
	@Transient
	public String getDelFlagDesc() {
		String delFlagDesc = "";
		if (IOrganizationJoinService.INSPECT_SUCCESS.equals(this.getDelFlag())) {
			delFlagDesc = "审核通过";
		} else if (IOrganizationJoinService.INSPECT_FAIL.equals(this.getDelFlag())) {
			delFlagDesc = "审核拒绝";
		}else{
			delFlagDesc = "待审核";
		}
		return delFlagDesc;
	} 
	
}
